package com.example.studentportrait.controller.admin;

import com.example.studentportrait.domain.ResponseResult;
import com.example.studentportrait.domain.dto.ListRoleDto;
import com.example.studentportrait.domain.dto.ListUserDto;
import com.example.studentportrait.domain.dto.RoleDto;
import com.example.studentportrait.domain.dto.UpdateRoleDto;
import com.example.studentportrait.service.RoleService;
import com.example.studentportrait.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin")
public class RoleController {
    @Autowired
    RoleService roleService;

    /**
     * 角色管理分页查询
     * @param pageNum
     * @param pageSize
     * @param listRoleDto
     * @return
     */
    @GetMapping("/roleList")
    public ResponseResult roleList(Integer pageNum, Integer pageSize, ListRoleDto listRoleDto){
        return roleService.roleList(pageNum,  pageSize,  listRoleDto);
    }

    /**
     * 新增角色
     * @param roleDto
     * @return
     */
    @PostMapping("/addRole")
    public ResponseResult addRole(@RequestBody RoleDto roleDto){
        return roleService.addRole(roleDto);
    }

    /**
     * 编辑角色
     * @param updateRoleDto
     * @return
     */
    @PutMapping("/updateRole")
    public ResponseResult updateRole(@RequestBody UpdateRoleDto updateRoleDto){
        return roleService.updateRole(updateRoleDto);
    }

    /**
     * 删除角色
     * @param id
     * @return
     */
    @DeleteMapping("/deleteRole/{id}")
    public ResponseResult deleteRole(@PathVariable("id") Long id){
        return roleService.deleteRole(id);
    }

    /**
     * 获取可选的权限
     * @return
     */
    @GetMapping("/getPermissionList")
    public ResponseResult getPermissionList(){
        return roleService.getPermissionList();
    }
}
